import request from '@/config/axios'

// 项目管理 VO
export interface ProjectVO {
  id: number // 编号
  name: string // 项目名称
  remark: string // 备注
}

// 项目管理 API
export const ProjectApi = {
  // 查询项目管理分页
  getProjectPage: async (params: any) => {
    return await request.get({ url: `/project/project/page`, params })
  },

  // 查询项目管理详情
  getProject: async (id: number) => {
    return await request.get({ url: `/project/project/get?id=` + id })
  },

  // 新增项目管理
  createProject: async (data: ProjectVO) => {
    return await request.post({ url: `/project/project/create`, data })
  },

  // 修改项目管理
  updateProject: async (data: ProjectVO) => {
    return await request.put({ url: `/project/project/update`, data })
  },

  // 删除项目管理
  deleteProject: async (id: number) => {
    return await request.delete({ url: `/project/project/delete?id=` + id })
  },

  // 导出项目管理 Excel
  exportProject: async (params) => {
    return await request.download({ url: `/project/project/export-excel`, params })
  },

// ==================== 子表（项目考核记录总） ====================

  // 获得项目考核记录总分页
  getCheckRecordPage: async (params) => {
    return await request.get({ url: `/project/project/check-record/page`, params })
  },
  // 新增项目考核记录总
  createCheckRecord: async (data) => {
    return await request.post({ url: `/project/project/check-record/create`, data })
  },

  // 修改项目考核记录总
  updateCheckRecord: async (data) => {
    return await request.put({ url: `/project/project/check-record/update`, data })
  },

  // 删除项目考核记录总
  deleteCheckRecord: async (id: number) => {
    return await request.delete({ url: `/project/project/check-record/delete?id=` + id })
  },

  // 获得项目考核记录总
  getCheckRecord: async (id: number) => {
    return await request.get({ url: `/project/project/check-record/get?id=` + id })
  },

  // 获得项目打分列表
  getScoreList: async (checkType: number) => {
    return await request.get({ url: `/project/project/check-record/getScoreList?checkType=` + checkType })
  },

  // 批量添加项目考核记录总
  addAreaRecordList: async (data) => {
    return await request.post({ url: `/project/area-record/addAreaRecordList`, data })
  },

  // 获取之前区域记录，进行回显
  getPreAreaRecord: async (projectId, checkType, assessmentBatchId) => {
    return await request.get({ url: `/project/area-record/getPreAreaRecord?projectId=${projectId}&checkType=${checkType}&assessmentBatchId=${assessmentBatchId}`})
  },

  //updateAreaRecordList
  updateAreaRecordList: async (data) => {
    return await request.put({ url: `/project/area-record/updateAreaRecordList`, data })
  },

  // getCleanScoreList
  getCleanScoreList: async () => {
    return await request.get({ url: `/project/cleaning-area/cleaning-area-detail/getCleanScoreList`})
  },

  // addCleanAreaRecordList, 添加进CleaningAreaDetailRecordDO表中
  addCleanAreaRecordList: async (data) => {
    return await request.post({ url: `/project/cleaning-area/cleaning-area-detail-record/addCleanAreaRecordList`, data })
  },

  // getPreCleanAreaRecord, 编辑，所以要查找之前的记录
  getPreCleanAreaRecord: async (projectId, assessmentBatchId) => {
    return await request.get({ url: `/project/cleaning-area/cleaning-area-detail-record/getPreCleanAreaRecord?projectId=${projectId}&assessmentBatchId=${assessmentBatchId}`})
  },

  // updateCleanAreaRecordList
  updateCleanAreaRecordList: async (data) => {
    return await request.put({ url: `/project/cleaning-area/cleaning-area-detail-record/updateCleanAreaRecordList`, data })
  },

  getAllProject: async () => {
    return await request.get({ url: `/project/project/getAllProject`})
  },


  // ==================== 子表（考核批次） ====================

  // 获得考核批次分页
  getAssessmentBatchPage: async (params) => {
    return await request.get({ url: `/project/project/assessment-batch/page`, params })
  },
  // 新增考核批次
  createAssessmentBatch: async (data) => {
    return await request.post({ url: `/project/project/assessment-batch/create`, data })
  },

  // 修改考核批次
  updateAssessmentBatch: async (data) => {
    return await request.put({ url: `/project/project/assessment-batch/update`, data })
  },

  // 删除考核批次
  deleteAssessmentBatch: async (id: number) => {
    return await request.delete({ url: `/project/project/assessment-batch/delete?id=` + id })
  },

  // 获得考核批次
  getAssessmentBatch: async (id: number) => {
    return await request.get({ url: `/project/project/assessment-batch/get?id=` + id })
  },
}
